<?php

namespace App\Http\Utils\Integral;

/**
 * Class UserContainer
 * @package App\Http\Utils\Integral
 */
trait ShopContainer
{
    /**
     * 用户列表
     * @var Shop[]
     */
    public $shops = [];

    /**
     * @param string $shopId
     * @return Shop
     */
    public function shop($shopId)
    {
        if (!array_key_exists($shopId, $this->shops)) {
            $this->shops[$shopId] = new Shop($shopId);
        }
        return $this->shops[$shopId];
    }

    /**
     * 记录
     */
    public function shopRecord()
    {
        foreach ($this->shops as $shop) {
            $shop->record();
        }
    }
}